package sjtu.ist.warehouse4ws.action;
import java.util.ArrayList;
import java.util.List;

import sjtu.ist.warehouse4ws.model.Company;
import sjtu.ist.warehouse4ws.model.Department;
import sjtu.ist.warehouse4ws.service.CompanyService;
import sjtu.ist.warehouse4ws.service.DepartmentService;

import org.apache.struts2.json.annotations.JSON;
import com.opensymphony.xwork2.ActionSupport;

public class CompanyAction extends ActionSupport {

	private CompanyService companyService;
	private List<Company> companyList = new ArrayList<Company>();
	
	//获得Company列表
	public String showAllCompanies(){
		this.companyList = companyService.getAllCompanies();
		return SUCCESS;
	}
	
	@JSON(name = "totalCompany")
	public int getTotalCompany() {
		return this.companyList.size();
	}

	@JSON(name = "Company")
	public List<Company> getCompanyList() {
		return this.companyList;
	}
	
	// 注入CompanyService
	public void setCompanyService(CompanyService companyService) {
		this.companyService = companyService;
	}
}